/*
   Class: Thunderbird
   Thunderbird object representation
 */

var ThunderbirdApp = function ()
{

    ThunderbirdApp.prototype.getMainWindow = function ()
    {
        this.mainWindow = new ThunderbirdMainWindow();
        return this.mainWindow;
    }

    ThunderbirdApp.prototype.getComposeWindow = function ()
    {
        composeWindow = new ThunderbirdComposeWindow();
        return this.composeWindow;
    }
}

var ThunderbirdPreferences = function ()
{

    this.prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("extensions.vanish.");
    
    ThunderbirdPreferences.prototype.isAutoDecapsulationEnabled = function ()
    {
        return this.prefs.getBoolPref("autodecapsulation");
    }    
    
}

var ThunderbirdMainWindow = function ()
{
    this.statusbar = document.getElementById("vanish-main-statusbar");
    this.currentReadMessage = document.getElementById("messagepane").contentDocument.body;
    this.vanishHeader = document.getElementById("header-vanish");
    this.vanishHeaderLabel = document.getElementById("vanish-label");
    this.vanishContextMenuSep = document.getElementById("vanish-messagePaneContextSeparator");
    this.vanishContextMenu = document.getElementById("vanish-messagePaneContextMenuitem");

    //var window = document.getElementById("messengerWindow");
    //window.addEventListener('command', onloadWindow, true);

    ThunderbirdMainWindow.prototype.disableContextMenu = function (state)
    {
        this.vanishContextMenu.setAttribute("hidden", state);
        this.vanishContextMenuSep.setAttribute("hidden", state);
    }

    ThunderbirdMainWindow.prototype.setVanishHeader = function (isHidden, stringVal)
    {
        this.vanishHeaderLabel.setAttribute("value", stringVal);
        this.vanishHeader.setAttribute("hidden", isHidden);
    }

    ThunderbirdMainWindow.prototype.getStatusBar = function ()
    {
        return this.statusbar.getAttribute("label");
    }

    ThunderbirdMainWindow.prototype.setStatusBar = function (stringVal)
    {
        this.statusbar.setAttribute("label", stringVal);
    }

    ThunderbirdMainWindow.prototype.getCurrentReadMessage = function ()
    {
        return this.currentReadMessage.textContent;
    }

    ThunderbirdMainWindow.prototype.setCurrentReadMessage = function (stringVal)
    {
        this.currentReadMessage.textContent = stringVal;
    }


}

var ThunderbirdComposeWindow = function ()
{
    this.statusbar = document.getElementById("vanish-msgcompose-statusbar");
    this.message = document.getElementById("content-frame").contentDocument.body;

    ThunderbirdComposeWindow.prototype.getStatusBar = function ()
    {
        return this.statusbar.getAttribute("label");
    }

    ThunderbirdComposeWindow.prototype.setStatusBar = function (stringVal)
    {
        this.statusbar.setAttribute("label", stringVal);
    }

    ThunderbirdComposeWindow.prototype.getMessage = function ()
    {
        return this.message.textContent;
    }

    ThunderbirdComposeWindow.prototype.setMessage = function (stringVal)
    {
        this.message.textContent = stringVal;
    }

}